﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;
//////using ESRI.ArcGIS.TOCControl;
using PlanningGIS.Framework;
using PlanningGIS.TocContextMenu.Form;

namespace PlanningGIS.TocContextMenu.Button
{

    /// <summary>
    /// 作用：TOC右键菜单设置标注按钮类
    /// 作者：
    /// 编写日期:2008-08-01
    internal  class SetLabel:BaseCommand
    {
        IApplication m_Application = null;
        public SetLabel()
        {
            base.m_caption = "设置标注";
            base.m_toolTip = base.Caption;
        }

        public override void OnCreate(object hook)
        {
            m_Application = hook as IApplication;
        }

        public override void OnClick()
        {
            FrmLabelSet frmLabelSet = new FrmLabelSet();
            IGeoFeatureLayer pLayer = (m_Application as IFramework).TOCControl.CustomProperty as IGeoFeatureLayer;
            frmLabelSet.GeoFeatLayer = pLayer;
            if (frmLabelSet.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (pLayer.DisplayAnnotation)
                {
                    (m_Application.Document as IMxDocument).ActiveView.Refresh();
                }
            }
        }

        public override bool Enabled
        {
            get
            {
                return ((m_Application as IFramework).IsMapCtrlactive && (m_Application as IFramework).TOCControl.CustomProperty is IGeoFeatureLayer) ? true : false;
            }
        }

    }
    
}
